// 
// 
// 

#include "HomeScreenClass.h"
#include "ControlPanelClass.h"
#include "constants.cpp"
/*
		MENU LAYOUT

	RUN LAST  |  CHANGE 
	HISTORY   |  SETTINGS 

*/
const char HOME_SCREEN_ONE[4][7] = {"Run","Change","Hist","Setup"};


void HomeScreenClass::RefreshMenu()
{
	this->PrintMenu(HOME_SCREEN_ONE, ActiveOption);
	delay(500);
}

void HomeScreenClass::init()
{


}

void HomeScreenClass::update()
{
	
	switch(ActiveOption)
	{
	case RERUN_LAST_PROG: 	//Top Left	
		if(ControlPanel.RightButtonPressed())
		{
			Serial.println("Right button pressed.");
			ActiveOption = SELECT_ANOTHER_PROG;
			RefreshMenu();
		}
		else if(ControlPanel.DownButtonPressed())
		{
			ActiveOption = VIEW_RUN_HISTORY;
			RefreshMenu();
		}
		else if(ControlPanel.EnterButtonPressed())
		{
			//TODO: Start last run
		}
		break;
	case SELECT_ANOTHER_PROG: break; //Top Right
		if(ControlPanel.LeftButtonPressed())
		{
			Serial.println("Left Button Pressed.");

			ActiveOption = RERUN_LAST_PROG;
			RefreshMenu();
		}
		else if(ControlPanel.DownButtonPressed())
		{
			ActiveOption = SETTINGS;
			RefreshMenu();
		}
		else if(ControlPanel.EnterButtonPressed())
		{
			//TODO: Change Active Menu in controlpanel
		}
	case VIEW_RUN_HISTORY: // Bottom Left
		if(ControlPanel.RightButtonPressed())
		{
			ActiveOption = SETTINGS;
			RefreshMenu();
		}
		else if(ControlPanel.UpButtonPressed())
		{
			ActiveOption = RERUN_LAST_PROG;
			RefreshMenu();
		}
		else if(ControlPanel.EnterButtonPressed())
		{
			//TODO: Set Run History Menu
		}
		break;
	case SETTINGS: break; //Bottom Right
		if(ControlPanel.LeftButtonPressed())
		{
			ActiveOption = VIEW_RUN_HISTORY;
			RefreshMenu();
		}
		else if(ControlPanel.UpButtonPressed())
		{
			ActiveOption = SELECT_ANOTHER_PROG;
			RefreshMenu();
		}
		else if(ControlPanel.EnterButtonPressed())
		{
			//TODO: Set Run History Menu
		}
	default: break;
	}

}

void HomeScreenClass::OnSetActive()
{
	ActiveOption = RERUN_LAST_PROG;	
	RefreshMenu();
	delay(200);
	Serial.println("Home screen active!");
}




HomeScreenClass HomeScreen;

